#include <qnetworkreply.h>
#include <qnetworkrequest.h>
#include <qnetworkaccessmanager.h>
#include "ServiceCallback.h"

ServiceCallback::ServiceCallback(QObject* parent):
QObject(parent)
{
}

ServiceCallback::~ServiceCallback()
{
}

void ServiceCallback::start(const QString& url)
{
    QNetworkAccessManager* manager = new QNetworkAccessManager(this);
    connect(manager,&QNetworkAccessManager::finished,[this,&manager](QNetworkReply* reply)
       {
           emit onCallback(reply->readAll());
           manager->deleteLater();
       }
    );

    QNetworkRequest request;
    request.setUrl(QUrl(url));
    manager->get(request);
}